package com.example.cslp.controller;

import com.example.cslp.pojo.VO.ResourceListVO;
import com.example.cslp.service.IResourceService;
import com.example.cslp.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ming
 */

@RestController
@RequestMapping("/resources")
public class ResourceController {

    @Autowired
    private IResourceService resourceService;

    @GetMapping("/list")
    public JsonResult list(){
        String msg="查询资源列表成功！！";
        List<ResourceListVO> list = resourceService.list();
        return JsonResult.ok(list,msg);
    }

    @GetMapping("/query/{resourceName}")
    public JsonResult query(@PathVariable String resourceName){
        List<ResourceListVO> queryList = resourceService.query(resourceName);
        String msg="根据资源名称查询成功!";
        return JsonResult.ok(queryList,msg);
    }
}
